package parent.cloud.ahri;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@RestController
public class AhriApplication {
    @RequestMapping("/ahri")
    public String ahri() {
        return "ahri is nice";
    }
    public static void main(String[] args) {
        SpringApplication.run(AhriApplication.class, args);
    }

    // 添加@LoadBalanced 注解后就有了负载均衡的能力
    @Bean
    @LoadBalanced   // 开启负载均衡功能
    public RestTemplate restTemplate() {
        return  new RestTemplate();
    }
}
